function test_api_callmt()
	require("DongleStub.lua")
	local succ,err = pcall(DongleStub, "Alpha")
	assert_match("Cannot find a library with name 'Alpha'", err)
	assert_table(DongleStub("DongleStub"))
end

function test_api_hasversion()
	require("DongleStub.lua")

	assert_pass(nil, DongleStub.HasVersion, DongleStub, "Alpha")
	assert_error(nil, DongleStub.HasVersion, DongleStub, nil)
	assert_error(nil, DongleStub.HasVersion, DongleStub, types.number)
	assert_error(nil, DongleStub.HasVersion, DongleStub, types.table)
	assert_error(nil, DongleStub.HasVersion, DongleStub, types.func)
	assert_error(nil, DongleStub.HasVersion, DongleStub, types.thread)

	local succ,err = pcall(DongleStub.HasVersion, DongleStub, nil)
	assert_match("bad argument #2 to 'HasVersion'", err)

	assert_false(DongleStub:HasVersion("Alpha"))
	assert_true(DongleStub:HasVersion("DongleStub"))
end

function test_api_isnewerversion()
	require("DongleStub.lua")
	local Alpha = makelib("Alpha", 1)

	assert_pass(nil, DongleStub.Register, DongleStub, Alpha)
	assert_table(DongleStub("Alpha"))

	assert_true(DongleStub:IsNewerVersion("Alpha", 2))
	assert_false(DongleStub:IsNewerVersion("Alpha", 1))
	assert_false(DongleStub:IsNewerVersion("Alpha", 0))
end

function test_api_register()
	require("DongleStub.lua")

	-- Test argument 1
	assert_error(nil, DongleStub.Register, DongleStub, types.string)
	assert_error(nil, DongleStub.Register, DongleStub, types.number)
	assert_error(nil, DongleStub.Register, DongleStub, types.func)
	assert_error(nil, DongleStub.Register, DongleStub, types.thread)

	local succ,err = pcall(DongleStub.Register, DongleStub, {})
	assert_match("Attempt to register a library with DongleStub that does not have a 'GetVersion' method.", err)

	local Alpha = makelib(nil, nil)
	local succ,err = pcall(DongleStub.Register, DongleStub, Alpha)
	assert_match("Attempt to register a library with DongleStub that does not have a proper major version.", err)

	local Alpha = makelib("Alpha", nil)
	local succ,err = pcall(DongleStub.Register, DongleStub, Alpha)
	assert_match("Attempt to register a library with DongleStub that does not have a proper minor version.", err)

	local Gamma = makelib("Gamma", 1)
	assert_pass(nil, DongleStub.Register, DongleStub, Gamma)
	assert_equal(DongleStub("Gamma"), Gamma)
end
